Add test to expose stacking claim bug #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a test to expose a stacking claim bug identified in Discord, where a user can claim their CityCoins back from the contract before the STX are distributed by the pool operator.
Adding the pinned message content from Discord as well:
STACKING CONTRACT BUG
There is a bug in the stacking contract (CCD007), such that if you claim your rewards before the cycle is paid by the pool operator, and have CityCoins that are eligible to return, then you will receive only the CityCoins and not the STX reward.
If you did not have CityCoins that were eligible for return, the bug would not have affected you, and the transaction would fail until the cycle is paid by the pool operator.
The good news is that the bug does not affect the math used to determine the cycle rewards, so for those who experienced it, we can create a CCIP to retroactively pay the STX rewards from the contract. This would come from the stacking treasury and does not affect the mining treasury that was stacked.
In the short term, we can mitigate this by having minecitycoins.com or any other front-end that allows user claims to check if the cycle is paid by the pool operator before allowing the user to claim. This would be a temporary fix until the bug is fixed in the contract, and can be done through the is-cycle-paid read-only function.
The long term fix for this would be to create a v2 of the stacking contract, as well as explore some simpler migration options then having everyone unstack and stack again.